
        [].indexOf || (Array.prototype.indexOf = function(v){
        for(var i = this.length; i-- && this[i] !== v;);
            return i;
        }); 
        
        function clearSelectedState(data) {
            var cities = data.split(' ');
  
            var city_items = $("a[id *= 'c-']");
            var selectedItems = "";
            
            for(var i =0 ;i<city_items.length;i++)
            {
                var item = city_items[i];
                var id = item.id.split('-')[1];
                var index = cities.indexOf(id);
                if (index > -1) {
                    selectedItems += "<li><a class='j a_del_sele' id='se-" + id + "' href='javascript:void(0);'>" + $(item).html() + "</a></li>";
                    $(item).addClass('seled');
                    cities[index] = "";
                }
                else {
                    $(item).removeClass('seled');
                }
            }
            
            $('#pop_sele').html(selectedItems);
            load_event_monitor($('#pop_sele'));
            //debugger;
        }
        
        $("#sh").click(function() {
        	$("select").css("visibility","hidden");
        	$('#select_location_title').html('期望工作地选择 ');
        	$('#kindly_reminder_text').html('( 温馨提示：点击已选项可取消选项。您最多只能选择4个城市。)');
            select_count = 4;
            clearSelectedState($('#sv').val());
            var arrayPageSize = getPageSize();
            var arrayPageScroll = getPageScroll();
            $('#pop').css('top', (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - 400) / 2) + 'px')).css('left', (((arrayPageSize[0] - 20 - 600) / 2) + 'px')).show();
            var h = arrayPageSize[1] + 35;
            $('#overlay').css('height', (h + 'px')).show();
        });

        $("#btnSelectLocation").click(function() {
        	$("select").css("visibility","hidden");
        	$('#select_location_title').html('当前居住地选择');
        	$('#kindly_reminder_text').html('( 温馨提示：点击已选项可取消选项 。您只能选择1个城市)');
            select_count = 1;
            clearSelectedState($('#hdlocation').val());
            var arrayPageSize = getPageSize();
            var arrayPageScroll = getPageScroll();
            $('#pop').css('top', (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - 400) / 2) + 'px')).css('left', (((arrayPageSize[0] - 20 - 600) / 2) + 'px')).show();
            var h = arrayPageSize[1] + 35;
            $('#overlay').css('height', (h + 'px')).show();
        });


        event_monitor.subscribe("sele_deled", function(o, data) {
            $('#c-' + data).removeClass('seled');
            if ($('#pc-' + data).length != 0) { $('#pc-' + data).removeClass('seled'); }
            var txt;
            if (select_count == 1) {//居住地
                $('#hdlocation').val($('#hdlocation').val().replace(data + ' ', ''));
                txt = getValue($('#hdlocation').val());
                $('#mylocation').html(txt);
                $('#se-' + data).remove();

            }
            else {//期望工作地
                $('#sv').val($('#sv').val().replace(data + ' ', ''));
                txt = getValue($('#sv').val())
                $('#mycity').html(txt);
                $('#se-' + data).remove();
            }
            /*
            if (SetContentAfterSelectedCity)
                SetContentAfterSelectedCity(txt, select_count);
            */
        });

        event_monitor.subscribe("sele_add", function(o, data) {
        var cv = null;
        var txt;
            if (select_count == 4) {//期望工作地
                cv = $('#sv').val();
                if (cv.lastIndexOf(data) < 0 && ja[data]) {
                    $('#sv').val($('#sv').val() + data + ' ');
                    txt = getValue($('#sv').val())
                    $('#mycity').html(txt);
                }
            }
            else {//居住地
                cv = $('#hdlocation').val();
                if (cv.lastIndexOf(data) < 0 && ja[data]) {
                    $('#hdlocation').val($('#hdlocation').val() + data + ' ');
                    txt = getValue($('#hdlocation').val());
                    $('#mylocation').html(txt);
                }
            }
            /*
            if (SetContentAfterSelectedCity)
                SetContentAfterSelectedCity(txt, select_count);
            */
                
            if (data.substring(2) == '00') {
                var key = ''; for (var i = 1; i < 20; i++) {
                    if (i < 10) key = data.substring(0, 2) + '0' + i; else key = data.substring(0, 2) + i;
                    event_monitor.broadcast(null, "sele_deled", key);
                }
            }
            else { event_monitor.broadcast(null, "sele_deled", data.substring(0, 2) + '00'); }
        });      